package com.faceye.test.util;

import com.jcraft.jsch.ChannelSftp;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import org.springframework.util.Assert;

import java.util.HashMap;
import java.util.Map;

@RunWith(JUnit4.class)
public class SFTPChannelTestCase {
    private Map properties=null;
    private SFTPChannel sftpChannel=null;
    private String src="c:/Wua.log";
    private String dst="/tmp/upload-2.txt";
    @Before
    public  void setUp() throws Exception{
        properties=new HashMap();
        properties.put(SFTPConstants.SFTP_REQ_HOST,"10.1.5.246");
        properties.put(SFTPConstants.SFTP_DEFAULT_PORT,"22");
//        properties.put(SFTPConstants.SFTP_REQ_LOC,"location");
        properties.put(SFTPConstants.SFTP_REQ_PORT,"22");
        properties.put(SFTPConstants.SFTP_REQ_PASSWORD,"hdp");
        properties.put(SFTPConstants.SFTP_REQ_USERNAME,"hdp");
        sftpChannel = new SFTPChannel();
    }
    @After
    public void tearDown() throws Exception{
        if(sftpChannel!=null){
            sftpChannel.closeChannel();
            sftpChannel=null;
        }
    }

    @Test
    public void testPut() throws Exception{
        sftpChannel.put(sftpChannel.getChannel(properties,1500),src,dst );
    }
    @Test
    public void testGetChannelSftp() throws Exception{
        sftpChannel.getChannel(properties,1500);
        Assert.isTrue(sftpChannel!=null);
    }
}
